{% load i18n %}
<html>
<body>
  <h1>{% trans "My shop" %}</h1>
  <p>
    {% trans "Invoice no." %} {{ order.id }}<br>
    <span class="secondary">
      {{ order.created|date:"M d, Y" }}
    </span>
  </p>
  <h3>{% trans "Bill to" %}</h3>
  <p>
    {{ order.first_name }} {{ order.last_name }}<br>
    {{ order.email }}<br>
    {{ order.address }}<br>
    {{ order.postal_code }}, {{ order.city }}
  </p>
  <h3>{% trans "Items bought" %}</h3>
  <table>
    <thead>
      <tr>
        <th>{% trans "Product" %}</th>
        <th>{% trans "Price" %}</th>
        <th>{% trans "Quantity" %}</th>
        <th>{% trans "Cost" %}</th>
      </tr>
    </thead>
    <tbody>
      {% for item in order.items.all %}
        <tr class="row{% cycle "1" "2" %}">
          <td>{{ item.product.name }}</td>
          <td class="num">${{ item.price }}</td>
          <td class="num">{{ item.quantity }}</td>
          <td class="num">${{ item.get_cost }}</td>
        </tr>
      {% endfor %}

      {% if order.coupon %}
        <tr class="subtotal">
          <td colspan="3">{% trans "Subtotal" %}</td>
          <td class="num">
            ${{ order.get_total_cost_before_discount|floatformat:2 }}
          </td>
        </tr>
        <tr>
          <td colspan="3">
            {% blocktrans with code=order.coupon.code discount=order.discount %}
              "{{ code }}" ({{ discount }}% off)
            {% endblocktrans %}
          </td>
          <td class="num neg">
            - ${{ order.get_discount|floatformat:2 }}
          </td>
        </tr>
      {% endif %}

      <tr class="total">
        <td colspan="3">{% trans "Total" %}</td>
        <td class="num">${{ order.get_total_cost|floatformat:2 }}</td>
      </tr>
    </tbody>
  </table>

  <span class="{% if order.paid %}paid{% else %}pending{% endif %}">
    {% if order.paid %}{% trans "Paid" %}{% else %}{% trans "Pending payment" %}{% endif %}
  </span>
</body>
</html>
